// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
// 引用编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 引入封装接口
Vue.use(VueQuillEditor)

// 引入element UI
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App';
// 引入路由
import router from './router';
// 引入状态管理
import store from './vuex/store';
// 引入icon
import './assets/icon/iconfont.css'
// 引入公共样式
import "./assets/css/global.css"
import Lxr from '../src/views/pageWorld/addCustomerData.vue'
Vue.component('Lxr',Lxr )
import Gjjl from '../src/views/pageWorld/addFollowUp.vue'
Vue.component('Gjjl',Gjjl )


//封装接口
import { post, domain } from '../config/http.js'
Vue.prototype.$post = post
Vue.prototype.domain = domain;
import cmsapi from './api/cms.js';
Vue.prototype.$cmsapi = cmsapi;
//图片放大
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
Vue.use(preview)
import echarts from 'echarts'  //引入echarts
Vue.prototype.$echarts = echarts
import axios from 'axios';
Vue.prototype.$axios = axios;

Vue.config.productionTip = false;
const wx = window.wx;
Vue.prototype.$wx = wx;

// 使用element UI
Vue.use(ElementUI);
// 过滤器
import * as custom from './utils/util'

Object.keys(custom).forEach(key => {
    Vue.filter(key, custom[key])
})

// 路由拦截器
router.beforeEach((to, from, next) => {
    if (to.path === '/' || to.path === '/login') {  //  
        //登录状态下 访问login.vue页面 会跳到index.vue
        next({ path: '/statistics' });
    } else {
        next();
    }
    // 判断该路由是否为当前系统所属-否则跳转404
    let platformNow = localStorage.routersData ? JSON.parse(localStorage.routersData).systemLayer : 'front';
    if (to.meta.platform && platformNow && to.meta.platform.indexOf(platformNow) === -1) {
        // next({ path: '/error' })
        next({ path: '/statistics' })
    } else {
        next()
    }
    // 判断当前登陆用户的角色权限
    // let jurisdictionUser = JSON.parse(localStorage.routersData).jurisdiction;
    // if(to.meta.roles.indexOf(jurisdictionUser)){
    // }
})
/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    store, //使用store vuex状态管理
    components: { App },
    template: '<App/>',
    data: {
        // 空的实例放到根组件下，所有的子组件都能调用
        Bus: new Vue()
    }

})